<template>
  <div class="home">
    <div class="nav">
      <rightNav></rightNav>
    </div>
    <div class="home-container">
      <div class="title"><div class="title-text">平达库存管理系统</div>
        <div class="drop">
          <el-dropdown @command="handleCommand">
            <span class="el-dropdown-link">
              我的账户<i class="el-icon-arrow-down el-icon--right"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item class="color" command="myCount">我的账户</el-dropdown-item>
              <el-dropdown-item class="color" command="loginOut">退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
      </div>
      <div class="view-container">
        <div id="pdfDom" class="view">
          <router-view/>
          <div class="footer">杭州平达电子机械有限公司 {{new Date().getFullYear()}}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
// import HelloWorld from '@/components/HelloWorld.vue'; // @ is an alias to /src
import rightNav from '@/components/homePageLeftNav.vue';

@Component({
  components: {
    rightNav
  }
})
export default class Home extends Vue {
  // data
  routerName: string = '';
  mounted() {
    console.log(this.$route);
  }
  handleCommand(index: string): void {
    console.log(index);
    if (index === 'loginOut') {
      sessionStorage.removeItem('token');
      this.$router.replace({ name: 'login' });
      this.$message.success('退出登录');
    } else if (index === 'myCount') {
      this.$to('myCount');
    }
  }
}
</script>
<style lang="less">
.home {
  display: flex;
  .title {
    position: relative;
    width: 100%;
    height: 55px;
    background-color: #d7d6d6;
    color: #000;
    .title-text {
      text-align: center;
      line-height: 55px;
      font-weight: 600;
    }
  }
  .nav {
    float: left;
    width: 140px;
    height: 100%;
    background-color: #555;
    box-sizing: border-box;
  }
  .home-container {
    flex: 1;
    overflow: hidden;
  }
  .drop {
    position: absolute;
    right: 20px;
    top: 18px;
    color: #409eff;
  }
  .el-dropdown {
    color: #2d8cf0;
  }
  .view-container {
    height: calc(~'100% - 55px');
    overflow: auto;
  }
  .footer {
    font-size: 12px;
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 60px;
    line-height: 60px;
    // padding: 5px 0;
    // margin-top: 20px;
    color: rgba(0, 0, 0, 0.4);
    text-align: center;
    border-top: 1px solid;
    border-color: rgba(0, 0, 0, 0.2);
  }
  .view {
    background-color: #f3f3f3;
    padding-bottom: 60px;
    min-height: 100%;
    // display: flex;
    // flex-direction: column;
    // flex: 1;
    box-sizing: border-box;
    position: relative;
  }
  .daochu-btn {
    position: absolute;
    right: 90px;
    top: 15px;
  }
}
</style>
